<!-- Modal -->
<div class="modal fade " id="addDimensionModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
    <div class="modal-dialog" role="document">
        <div class="box box-info">
            <div class="box-header with-border">
                <h3 class="box-title">维护维度</h3>
            </div>
            <!-- /.box-header -->
            <!-- form start -->
            <form class="form-horizontal">
                <div class="box-body">
                    <div class="form-group">
                        <label class="col-sm-2 control-label">财报年</label>
                        <div class="col-sm-7">
                            <input id="dimensionModelName" type="text" class="form-control" style="width: 100%;"
                                   readonly>
                            <input id="dimensionModelId" type="hidden">
                            <input id="dimensionId" type="hidden">
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="inputEmail3" class="col-sm-2 control-label">维度名称</label>
                        <div class="col-sm-7">
                            <input id="dimensionName" type="text" class="form-control">
                        </div>
                    </div>
                    <div class="form-group" id="weightDiv">
                        <label for="inputEmail3" class="col-sm-2 control-label">维度权重</label>
                        <div class="col-sm-7">
                            <input type="text" class="form-control" id="dimensionWeight">
                        </div>
                    </div>
                </div>
                <!-- /.box-body -->
                <div class="box-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                    <button type="button" class="btn btn-primary pull-right" onclick="saveDimensionQuotaType()">保存
                    </button>
                </div>
                <!-- /.box-footer -->
            </form>
        </div>
    </div>
</div>

<script>

    function dimensionInit() {
        $("#dimensionId").val("");
        $("#dimensionModelName").val("");
        $("#dimensionModelId").val("");
        $("#dimensionName").val("");
        $("#dimensionWeight").val("");
    }
    function dimensionSetValue(row) {
        $("#dimensionId").val(row.id);
        $("#dimensionName").val(row.name);
        $("#dimensionWeight").val(row.weight * 100 );
    }
    function saveDimensionQuotaType() {
        var data = {
            id:$("#dimensionId").val(),
            modelId: $("#dimensionModelId").val(),
            name: $("#dimensionName").val(),
            weight: $("#dimensionWeight").val()
        };
        var url = "/scoremodel/dimension/add";
        if(data.id != "" && data.id != undefined) {
            url = "/scoremodel/dimension/modify" ;
        }
        postReq(url, data, function (result) {
            if (result.success) {
                toastr['success']('操作成功', '提示');
                refreshTable('table1');
                $("#addDimensionModal").modal("hide");
            } else {
                toastr['error'](result.msg, '提示');
            }
        });
    }
</script>
